<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/7/21
 * Time: 17:41
 */
namespace app\admin\controller;
use think\Db;
use think\Request;
class Other extends Base {
    /**
     * 用户协议
     * @return mixed|\think\response\Json
     */
    public function userAgreement(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id', 1)
                ->update(['other_user_agreement' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 1)->value('other_user_agreement');
        $this->assign('agreement', $agreement);
        return $this->fetch('other/useragreement');
    }
    /**
     * 联系我们
     * @return mixed|\think\response\Json
     */
    public function userPhone(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
             Db::table('up_other')
                ->where('other_id', 2)
                ->update(['other_phone' => $agreement]);
            return json(['code' => 200, 'msg' => '保存成功']);
        }
        $agreement = Db::table('up_other')->where('other_id', 2)->value('other_phone');
        $this->assign('agreement', $agreement);
        return $this->fetch('other/userphone');
    }
    /**
     * 版本介绍
     * @return mixed|\think\response\Json
     */
    public function bbjs(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id', 3)
                ->update(['other_bbjs' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 3)->value('other_bbjs');
        $this->assign('agreement', $agreement);
        return $this->fetch();
    }

    /**
     * 法律声明
     * @return mixed|\think\response\Json
     */
    public function flsm(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id', 4)
                ->update(['other_flsm' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 4)->value('other_flsm');
        $this->assign('agreement', $agreement);
        return $this->fetch();
    }
    /**
 * 平台协议
 * @return mixed|\think\response\Json
 */
    public function ptxy(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id',5)
                ->update(['other_ptxy' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 5)->value('other_ptxy');
        $this->assign('agreement', $agreement);
        return $this->fetch();
    }
    /**
     * 功能介绍
     * @return mixed|\think\response\Json
     */
    public function gnjs(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id',6)
                ->update(['other_gnjs' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 6)->value('other_gnjs');
        $this->assign('agreement', $agreement);
        return $this->fetch();
    }

    /**
     * 合伙人
     * @return mixed|\think\response\Json
     */
    public function hhr(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id',7)
                ->update(['other_hhr' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 7)->value('other_hhr');
        $this->assign('agreement', $agreement);
        return $this->fetch();
    }
    /**
     * 投放广告
     * @return mixed|\think\response\Json
     */
    public function tfgg(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id',8)
                ->update(['other_tfgg' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 8)->value('other_tfgg');
        $this->assign('agreement', $agreement);
        return $this->fetch();
    }

    /**
     * 企业简介
     * @return mixed|\think\response\Json
     */
    public function qyjj(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id',9)
                ->update(['other_qyjj' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 9)->value('other_qyjj');
        $this->assign('agreement', $agreement);
        return $this->fetch();
    }

    /**
     * 企业精神
     * @return mixed|\think\response\Json
     */
    public function qyjs(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id',10)
                ->update(['other_qyjs' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 10)->value('other_qyjs');
        $this->assign('agreement', $agreement);
        return $this->fetch();
    }

    public function price(){
        if(Request::instance()->isPost()){
            $agreement = input('price');
            $res = Db::table('up_other')
                ->where('other_id',11)
                ->update(['other_price' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 11)->value('other_price');
        $this->assign('agreement', $agreement);
        return $this->fetch();
    }
}